<?php
class serviceAdminBase extends Activity {
    /** @var CmsView  */
    protected $cms;
    /** @var  UserModule */
    protected $user;
    /** @var  array */
    protected $serviceInfo;
    function __construct() {
        $this->user=UserModule::init("user");
        if(!$this->user->checkLogin()){
            $_SESSION['user_login_call_back']=$_SERVER['REQUEST_URI'];
            header("Location:".WebRouter::init()->getAbsolute("user/login"));
            exit();
        }
        $userInfo=$this->user->getLoginInfo();
        if($userInfo['type']!='service'&&$userInfo['type']!='both'){
            $re['message']="您不是服务站，无法进入服务站后台";
            $re['url']=WebRouter::init()->getAbsolute("");
            View::displayAsHtml($re, 'plugin/state/tips.php');
            exit();
        }
        $serviceMode=ServiceMode::init();
        $this->serviceInfo=$serviceMode->getDetail($serviceMode->getServiceId($userInfo['id']));
        if($this->serviceInfo['enable']==0){
            $re['message']="服务站申请暂未审核，无法进入服务站后台，请耐心等待";
            $re['url']=WebRouter::init()->getAbsolute("");
            View::displayAsHtml($re, 'plugin/state/tips.php');
            exit();
        }
        $this->cms=CmsView::init(null, null, array(
            "navFile"=>"service/nav.json",
            "userInfoFile"=>"service/userinfo.json",
            "controlFile"=>"",
        ));
        $this->cms->setUserName($this->serviceInfo['service_name']);
    }
}
